package editor.graphics;

import javax.swing.*;
import java.awt.event.MouseListener;
import java.awt.event.MouseEvent;
import java.awt.*;

public class SpritePanel extends JPanel implements MouseListener {
	protected String spriteMap;
	protected String theme;
	protected String id;
	protected BrushSelectionListener brushSelectionListener;
	protected ImageIcon spriteImage;

	public SpritePanel(String spriteMap, String theme, String id, ImageIcon spriteImage, BrushSelectionListener brushSelectionListener) {
		this.spriteMap = spriteMap;
		this.theme = theme;
		this.id = id;
		this.spriteImage = spriteImage;
		this.brushSelectionListener = brushSelectionListener;
		JLabel label = new JLabel(spriteImage);
		label.setToolTipText(id);
		label.addMouseListener(this);
		add(label);
		addMouseListener(this);
	}

	@Override
	public void mouseClicked(MouseEvent e) {
	}

	@Override
	public void mousePressed(MouseEvent e) {
		brushSelectionListener.spriteSelected(spriteMap, theme, id, spriteImage);
	}

	@Override
	public void mouseReleased(MouseEvent e) {
	}

	@Override
	public void mouseEntered(MouseEvent e) {
	}

	@Override
	public void mouseExited(MouseEvent e) {
	}
}
